import { createRouter, createWebHashHistory } from 'vue-router'

//路由配置
const router = createRouter(
    {
        //hash模式,默认
        history: createWebHashHistory(),
        //history模式,默认是hash模式
        //区别是hash模式地址栏带#,/#/index
        //history模式,地址栏不带#,/index
        //history: createWebHistory(),
        //配置路由
        routes: [
            {
                path: '/',
                redirect: '/record'
            },
            {
                path: '/record',
                name: 'record',
                component: () => import('@/views/record.vue')
            },
            {
                path: '/square',
                name: 'square',
                component: () => import('@/views/square.vue')
            },
            {
                path: '/shop',
                name: 'shop',
                component: () => import('@/views/shop.vue')
            },
            {
                path: '/personal',
                name: 'personal',
                component: () => import('@/views/personal.vue')
            },
            {
                path: '/search',
                component: () => import('../components/search/Search.vue')
            },
            {
                path: '/search/result',
                redirect: (to) => {
                    // 重定向到搜索页并带上参数
                    return {
                        path: '/search',
                        query: { keyword: to.query.keyword }
                    }
                }
            },
            {
                path: '/notifications',
                name: 'Notifications',
                component: () => import('../components/notify/Notifications.vue'),
            },
            {
                path:'/messageDetail/:id',
                name:'MessageDetail',
                component:()=>import('../components/notify/MessageDetail.vue')
            },
            {
                path:'/orderDetail/:id/:status',
                name:'OrderDetail',
                component:()=>import('../components/notify/OrderDetail.vue')
            },
            {
                path:'/commentDetail/:id/:status',
                name:'CommentDetail',
                component:()=>import('../components/notify/CommentDetail.vue')
            },
            {
                path: '/clock-in',
                name: 'clockIn',
                component: () => import('../components/Square/Clockin2.vue')
            },
            {
                path: '/diet',
                name: 'diet',
                component: () => import('../components/Square/Diet.vue')
            },
            {
                path: '/experience',
                name: 'experience',
                component: () => import('../components/Square/experience.vue')
            },
            {
                path: '/qa',
                name: 'qa',
                component: () => import('../components/Square/QA.vue')
            },
            {
                path: '/tutorial',
                name: 'tutorial',
                component: () => import('../components/Square/Tutorial.vue')
            },

            {
                path: '/postfs',
                name: 'postfs',
                component: () => import('../components/Square/Postfs.vue')
            },
            {
                path: '/comment',
                name: 'comment',
                component: () => import('../components/Square/Comment.vue')
            },
            {
                path: '/follow',
                name: 'follow',
                component: () => import('../components/Square/follow.vue')
            },


        ]
    }
)
//导出路由后才能使用
export default router
